home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d13 / patch12.arc / TCPATCH5.DIF < prev    next >
Text File  |  1990-10-02  |  4KB  |  175 lines

  1. TurboC2.0 Patches to fix pipe bugs
  2. Prereq: 4
  3. *** tcpatlev.h    Wed Jul 18 15:48:16 1990
  4. --- tcpatlev.new    Tue Aug 07 08:31:10 1990
  5. ***************
  6. *** 1,1 ****
  7. ! #define TCPATCHLEVEL 4
  8. --- 1,1 ----
  9. ! #define TCPATCHLEVEL 5
  10. *** readme    Wed Jul 18 15:39:48 1990
  11. --- readme.new    Tue Aug 07 08:31:10 1990
  12. ***************
  13. *** 182,184 ****
  14. --- 182,201 ----
  15.   in the current implementation.
  16.   
  17.   (this bug is now fixed)
  18. + *** OFFICIAL PATCHLEVEL 12, TurboC2.0 PATCHLEVEL 5
  19. + From: aas@cc.uq.oz.au (Alex Sergejew)
  20. + Date: Fri, 20 Jul 90 23:56:13 EST
  21. + The problem is that whatever ed is doing it's not accepting the
  22. + redirected stdin from the shelled COMMAND.COM and so it stalls.  When you
  23. + hit q it unstalls and also returns normally but hasn't read the ed script.
  24. +
  25. + Appended find *more* patches, this time to a pipe package that *does* work
  26. + the way it ought to, along with appropriate mods to pch.c and makefile
  27. + (ie patches to my patches to your patches to etc).  The pipe package here
  28. + was snarfed from an old edition of lharc and is more limited than the fancy
  29. + one I posted but it works just fine with patch (it does stdin redirection
  30. + from the invocation of the spawned COMMAND.COM - quite foolproof).
  31. *** makefile.bak    Sun Jul 15 15:59:34 1990
  32. --- makefile    Fri Jul 20 21:54:12 1990
  33. ***************
  34. *** 1,14 ****
  35.   CC = tcc
  36.   CFLAGS = -N -ml -DTURBOC20
  37.   
  38. ! c = patch.c pch.c inp.c version.c util.c popen.c getswitc.c
  39. ! obj = patch.obj pch.obj inp.obj version.obj util.obj popen.obj getswitc.obj
  40.   
  41.   .c.obj:
  42.       $(CC) -c $(CFLAGS) $(LARGE) $*.c
  43.   
  44.   patch.exe: $(obj)
  45. !     $(CC) -epatch $(CFLAGS) $(obj)
  46.   
  47.   patch.obj: config.h common.h patch.c inp.h pch.h util.h version.h
  48.   
  49. --- 1,17 ----
  50.   CC = tcc
  51.   CFLAGS = -N -ml -DTURBOC20
  52. + LFLAGS = -ml
  53.   
  54. ! #c = patch.c pch.c inp.c version.c util.c popen.c getswitc.c
  55. ! #obj = patch.obj pch.obj inp.obj version.obj util.obj popen.obj getswitc.obj
  56. ! c = patch.c pch.c inp.c version.c util.c pipes.c
  57. ! obj = patch.obj pch.obj inp.obj version.obj util.obj pipes.obj
  58.   
  59.   .c.obj:
  60.       $(CC) -c $(CFLAGS) $(LARGE) $*.c
  61.   
  62.   patch.exe: $(obj)
  63. !     $(CC) -epatch $(LFLAGS) $(obj)
  64.   
  65.   patch.obj: config.h common.h patch.c inp.h pch.h util.h version.h
  66.   
  67. *** pch.bak    Sun Jul 15 18:54:58 1990
  68. --- pch.c    Fri Jul 20 22:17:22 1990
  69. ***************
  70. *** 41,49 ****
  71.   #include "util.h"
  72.   #include "INTERN.h"
  73.   #include "pch.h"
  74. - #ifdef TURBOC20
  75. - #include "popen.h"
  76. - #endif
  77.   
  78.   /* Patch (diff listing) abstract type. */
  79.   
  80. --- 41,46 ----
  81. *** /dev/null
  82. --- pipes.c    Fri Jul 20 21:52:54 1990
  83. ***************
  84. *** 0 ****
  85. --- 1,84 ----
  86. + /* a simulation for the Unix popen() and pclose() calls on MS-DOS */
  87. + /* only one pipe can be open at a time */
  88. + #include <stdio.h>
  89. + #include <stdlib.h>
  90. + #include <string.h>
  91. + #include <io.h>
  92. + static char pipename[128], command[128];
  93. + static int wrpipe;
  94. + static void Mktemp(char *);
  95. + FILE *popen(char *cmd, char *flags)
  96. + {
  97. +   wrpipe = (strchr(flags, 'w') != NULL);
  98. +   if ( wrpipe )
  99. +   {
  100. +     strcpy(command, cmd);
  101. +     strcpy(pipename, "~WXXXXXX");
  102. +     Mktemp(pipename);
  103. +     return fopen(pipename, flags);  /* ordinary file */
  104. +   }
  105. +   else
  106. +   {
  107. +     strcpy(pipename, "~RXXXXXX");
  108. +     Mktemp(pipename);
  109. +     strcpy(command, cmd);
  110. +     strcat(command, ">");
  111. +     strcat(command, pipename);
  112. +     system(command);
  113. +     return fopen(pipename, flags);  /* ordinary file */
  114. +   }
  115. + }
  116. + int pclose(FILE *pipe)
  117. + {
  118. +   int rc;
  119. +   if ( fclose(pipe) == EOF )
  120. +     return EOF;
  121. +   if ( wrpipe )
  122. +   {
  123. +     if ( command[strlen(command) - 1] == '!' )
  124. +       command[strlen(command) - 1] = 0;
  125. +     else
  126. +       strcat(command, "<");
  127. +     strcat(command, pipename);
  128. +     rc = system(command);
  129. +     unlink(pipename);
  130. +     return rc;
  131. +   }
  132. +   else
  133. +   {
  134. +     unlink(pipename);
  135. +     return 0;
  136. +   }
  137. + }
  138. + static
  139. + void Mktemp(char *file)
  140. + {
  141. +   char fname[32], *tmp, *bsp;
  142. +   tmp = getenv("TMP");
  143. +   if ( tmp != NULL )
  144. +   {
  145. +     strcpy(fname, file);
  146. +     bsp = strcpy(file, tmp);
  147. +     while ((bsp=strchr(bsp, '/')) != NULL)
  148. +         *bsp = '\\';
  149. +     if ( file[strlen(file) - 1] != '\\' )
  150. +       strcat(file, "\\");
  151. +     strcat(file, fname);
  152. +   }
  153. +   mktemp(file);
  154. + }
  155.  
  156.